package Example15;


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String str=scanner.next();
        List<MyMap> list=new ArrayList<>();
        StringBuilder sb=new StringBuilder();
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            int k=0;
            MyMap myMap=new MyMap(k,chars[i]);
            if(list.contains(myMap)){
                myMap=null;
                continue;
            }

            for (int j = 0; j < chars.length; j++) {
                if(chars[i]==chars[j])
                    k++;
            }
            myMap.count=k;
            list.add(myMap);
        }
        list.sort(new Comparator<MyMap>() {
            @Override
            public int compare(MyMap o1, MyMap o2) {
                return o1.count-o2.count;
            }
        });
        for (MyMap m : list) {
            for (int i = 0; i < m.count; i++) {
                sb.append(m.character);
            }
        }
        System.out.println(sb.reverse().toString());
    }

    static class MyMap{
        public int count=0;
        public Character character;

        public MyMap(int count,Character character){
            this.count=count;
            this.character=character;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof MyMap)) return false;
            MyMap myMap = (MyMap) o;
            return Objects.equals(character, myMap.character);
        }

        @Override
        public int hashCode() {
            return Objects.hash(count, character);
        }
    }
}
